package com.soar.recruitment.module.user.ui.fragment;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.soar.recruitment.R;
import com.soar.recruitment.common.dal.event.BaseEvent;
import com.soar.recruitment.common.ui.fragment.SOARBaseBackFragment;
import com.soar.recruitment.common.ui.view.MyEditView;
import com.soar.recruitment.common.ui.view.roundview.RoundTextView;
import com.soar.recruitment.common.util.SoarLoadDialog;
import com.soar.recruitment.module.user.bll.controller.ForgetContrats;
import com.soar.recruitment.module.user.bll.controller.ForgetPresenter;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;

/**
 * 忘记密码 - 第二步
 */
public class FotgetResetPwdFragment extends SOARBaseBackFragment implements ForgetContrats.View {

    private ForgetContrats.Presenter mPresenter;

    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @BindView(R.id.pwdEditView)
    MyEditView pwdEditView;

    @BindView(R.id.rtv_ok)
    RoundTextView rtv_ok;

    public static FotgetResetPwdFragment newInstance() {
        Bundle args = new Bundle();
        FotgetResetPwdFragment fragment = new FotgetResetPwdFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int initLayout() {
        return R.layout.fragment_forget_resetpwd;
    }

    @Override
    public void initVariable() {
        mPresenter = new ForgetPresenter(this);
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        initToolbarNavBlack(toolbar);
        toolbar.setTitle("忘记密码");

        rtv_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPresenter.resetPwdStep2();
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public String getPwdNum() {
        return pwdEditView.getText();
    }

    @Override
    public String getPhoneNum() {
        return null;
    }

    @Override
    public String getCodeNum() {
        return null;
    }

    @Override
    public void showLoading(String msg) {
        SoarLoadDialog.showLoadDialog(mActivity, msg);
    }

    @Override
    public void closeLoading() {
        SoarLoadDialog.closeLoadDialog();
    }

    @Override
    public void goNext() {
        // FIXME: 2017/7/12 关闭界面回到登录页
//        EventBus.getDefault().post(new BaseEvent());
//        _mActivity.onBackPressed();

        _mActivity.finish();
    }
}
